using System;
using System.Collections.Generic;
using System.Text;

namespace Guestbook.Page
{
    public class LoginPage : BasePage
    {
        protected System.Web.UI.WebControls.TextBox txtGuestBookId;
        protected System.Web.UI.WebControls.TextBox txtEmail;

        public int GuestBookId
        {
            get { return int.Parse(txtGuestBookId.Text.Trim()); }
        }

        public string UserEmail
        {
            get { return txtEmail.Text.Trim(); }
        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnRequest_Click(object sender, EventArgs e)
        {
            Guestbook.domain.GuestBook obj =
                Guestbook.business.service.GuestBookService.GetSelfGuestBookByEmail(this.UserEmail);

            if (obj != null)
            {
                //send email
            }
        }

        protected void btnGoto_Click(object sender, EventArgs e)
        {
            try
            {
                bool isExist = Guestbook.domain.GuestBook.IsExist(int.Parse(txtGuestBookId.Text.Trim()));

                if (isExist)
                    Response.Redirect(string.Format("~/admin/login.aspx?id={0}", this.GuestBookId));
            }
            catch (Exception)
            {
                //todo
            }
        }
    }
}
